WIFI P2P User Guide
1. Overview¶
This article mainly introduces the use of SSTAR WIFI P2P under Linux. Both GC and GO use wpa_supplicant to communicate. The following wpa_supplicant uses Version 2.6.
Note:
If the demo board and phone are connected to the computer of Windows 10 via wifi display, according to the test, if the picture is not uploaded in about 1 minute, the connection will be dropped, and the P2P_LISTEN
needs to be executed again.
2. Compile the Macros¶
Choose one of NL80211 and WEXT, it is recommended to use NL80211.
Open WPS related macros, P2P will finally connect by WPS.
Open 80211N, the GO mode supports 11n.
3. Configuration¶
Required flies:
ctrl_interface=/tmp/p2p_supplicant //Create netlink to interact with wpa_supplicant update_config=1 //The connected device refreshes the configuration file here device_name=IPC_DEVICES2 //Name of the device being broadcast device_type=10-0050F204-5 //Many types, you can configure this file directly for testing config_methods=virtual_push_button physical_display keypad //Configure according to this file p2p_ssid_postfix=-IPC_DEVICES2 persistent_reconnect=1 //Reconnection
Optional files:
p2p_listen_reg_class=81 p2p_listen_channel=1 p2p_oper_reg_class=115 p2p_oper_channel=36 p2p_go_intent=15 //The level negotiated between go and gc, 15 is the highest, which is the level of go (after configuration, the module is always go, which is ap) country=CN
4. Steps¶
4.1. Set Device to GO Mode¶
-
Run wpa_supplicant
SSTAR WIFI can only use p2p0.
p2p_supplicant.conf:
wpa_supplicant –ip2p0 –Dnl80211 –c p2p_supplicant.conf –B
Because the device is to be used as GO, a dhcp server needs to be configured.
ifconfig p2p0 192.168.100.1 dnsmasq interface=wlan0 --no-daemon --no-resolv --leasefile-ro --no-poll --dhcp-range=192.168.100.2,192.168.100.254,12h &
-
Enter the interface that interacts with wpa_supplicant
wpa_cli –p /tmp/p2p_supplicant
-
Set P2P parameters
SET wifi_display 1 WFD_SUBELEM_SET 0 000600111c440032 P2P_FLUSH P2P_SET listen_channel 6 P2P_LISTEN
After execution, IPC_DEVICES2 can be found on the corresponding interface of the phone or PC with windows 10.
P2P interface on the PC with Windows 10:
P2P interface on the phone:
-
The board actively connects to the phone in GO mode
-
P2p_find 10
Search for 10 seconds; it can be stopped by p2p_stop_find
-
p2p_peers
Check the searched P2P device, only connect to the device with mac address.
-
p2p_connect 02:08:22:da:fc:fb pbc go_intent=15
Connect to phone as GO. After entering the command on the board, wait for the phone to confirm:
Phone display:
After the phone is accepted:
Note: Please confirm as soon as possible, otherwise there will be a timeout error.
-
-
The phone actively connects to the board, and the device forces the GO mode to connect
-
P2P_SET listen_channel 6
P2P_LISTEN, set the monitoring channel and enter the monitoring mode, the phone will display the device.
-
The phone initiates a connection
The board prints as follows:
-
The board is forced to act as GO to answer the connection initiated by the phone
-
Connecting states
-
-
The device is in GO mode, and the phone actively connects to the board
The phone initiates a connection
Confirm the connection on the board
Note:
-
Please respond as soon as possible after the phone requests connection, otherwise there will be a timeout error.
-
The phone initiates the connection, if the picture is failed to send in about 1 minute, the connection will be dropped.
-
-
Check the states and connected device
-
Disconnect the phone, the board is still in GO mode
-
Disconnect the board, it will exit GO mode
Enter disconnect in the command interactive interface.
4.2. Set Device to GC Mode¶
-
Run wpa_supplicant
SSTAR WIFI can only use p2p0.
p2p_supplicant.conf:
wpa_supplicant –ip2p0 –Dnl80211 –c p2p_supplicant.conf –B
-
Enter the interface that interacts with wpa_supplicant
wpa_cli –p /tmp/p2p_supplicant
-
Set P2P parameters
SET wifi_display 1 WFD_SUBELEM_SET 0 000600111c440032 P2P_FLUSH P2P_SET listen_channel 6 P2P_LISTEN
After execution, IPC_DEVICES2 can be found on the corresponding interface of the phone or PC with windows 10.
P2P interface on the PC with Windows 10:
P2P interface on the phone:
-
The board actively initiates a connection in GC mode
-
P2p_find 10, search for 10 seconds
-
p2p_peers
Check the searched P2P device, only connect to the device with mac address.
-
p2p_connect 02:08:22:da:fc:fb pbc go_intent=0
Connect to phone as GC. After entering the command on the board, wait for the phone to confirm:
Phone display:
The following is the print on the board after the phone confirms:
-
Exit after connected, and get IP
-
Check states
-
-
The phone actively connects to the board, and the board answers the connection in GC mode
-
P2P_SET listen_channel
6 P2P_LISTEN
set the monitoring channel and enter the monitoring mode, the phone will display the device.
-
The phone initiates a connection
The board prints as follows:
-
The board is forced to act as GC to answer the connection initiated by the phone
-
Successfully connected, and get IP
-
-
Disconnect
Disconnect on the phone or input disconnect on the board.
4.3. Set Device to GC Mode(AP)¶
-
p2p_supplicant.conf
ctrl_interface=/tmp/p2p_supplicant update_config=1 device_name=IPC_DEVICES2 device_type=10-0050F204-5 config_methods=virtual_push_button physical_display keypad p2p_listen_reg_class=81 p2p_listen_channel=1 p2p_oper_reg_class=115 p2p_oper_channel=36 p2p_go_intent=15 p2p_ssid_postfix=-IPC_DEVICES2 #Add the following content p2p_passphrase_len=8 #Password length limit to 8 p2p_no_group_iface=1 max_num_sta=8 #Max connection num is 8 network={ ssid="DIRECT-IPC_DEVICES2"#ssid should start with DIRECT- psk="12345678" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN mode=3 disabled=2 }
-
Run wpa_supplicant
First execute
rm -f /dev/random;ln -s /dev/urandom /dev/random;
and thenwpa_supplicant -Dnl80211 -ip2p0 -c p2p_supplicant.conf -B
-
Enter the interface that interacts with wpa_supplicant
Make P2P broadcast with ssid so that the phone can search for:
wpa_cli –p /tmp/p2p_supplicant SET wifi_display 1 wpa_cli –p /tmp/p2p_supplicant WFD_SUBELEM_SET 0 000600111c440032
-
Force into GO mode
wpa_cli –p /tmp/p2p_supplicant P2P_GROUP_ADD persistent=0
Parameter:
P2P_GROUP_ADD; Force into GO mode.
persistent=0
Set persistent to 1, a network config item will be generated in
p2p_supplicant.conf
, ssid will add Direct-xx information in front of ssid in the above figure, and pwd will change accordingly, resulting in failure to connect normally when entering the password(12345678).Set persistent to 0, the network config item will be generated, the ssid in beacon is the ssid in the network configured in p2p_supplicant.conf.
-
GO name searched on the phone
-
Phone initiates a connection
ap found on mobile wifi interface
-
Use your phone as sta to connect to ap
GO (AP) print information:
Note: There is no need to send commands, connecting sta is the same as connecting ap.